function KeyManager() {
    var self = this;
    this.accounts = [{
        "address": "0x2e8c60e63f0fb6eb8d5d9c88ed614a48b4208cf7",
        "crypto": {
            "cipher": "aes-128-ctr",
            "cipherparams": {
                "iv": "312afccf569cade11afdb20720a3e29b"
            },
            "ciphertext": "c0daf3bd5ff3a656f04df04bc5d7fb1af6d727159268f0be9f59a186d461ab54",
            "kdf": "scrypt",
            "kdfparams": {
                "dklen": 32,
                "n": 262144,
                "p": 1,
                "r": 8,
                "salt": "07048a1729976382568ab83448cd4814908cb06e7f737a0816a73c580caf80e7"
            },
            "mac": "36609d0c87e771fa8b95eb12985c3e381894fb7449f6cb0f428eec898d9ce1b0"
        },
        "id": "300ffa48-864f-22a1-f0d4-1c9fc9f3cdca",
        "version": 3,
        "privateKey": null
    }, {
        "address": "0x0843ff8980108c1dd3d2d0cde3c3b4635dcb1a69",
        "crypto": {
            "cipher": "aes-128-ctr",
            "cipherparams": {
                "iv": "2bdc227a3819c977be73ac9486eae4f6"
            },
            "ciphertext": "dd853d302ac2be6435a2ab79fd159dc3dfd34983500a6c3fdd18cb2f55a070f5",
            "kdf": "scrypt",
            "kdfparams": {
                "dklen": 32,
                "n": 262144,
                "p": 1,
                "r": 8,
                "salt": "a05d2967b0d259e99198cb9e1de673888872edb84f4c058a083415046f782c36"
            },
            "mac": "70a55ede6c46ca09b512d33349d8d62299b2438691e2ac31d7a5d913a9e65d25"
        },
        "id": "47f306a8-f840-e49e-b790-9610d2e89476",
        "version": 3,
        "privateKey": null
    }, {
        "address": "0x00afd36a8f94642a9f16cb4b66f242b02004c55e",
        "crypto": {
            "cipher": "aes-128-ctr",
            "cipherparams": {
                "iv": "0ffff0f8e9a50f28974d7a29b9819aaa"
            },
            "ciphertext": "b0c44ca9f140cc0e8b6e26cff3495511f550169d9c164d401881eb9ac8ad88d0",
            "kdf": "scrypt",
            "kdfparams": {
                "dklen": 32,
                "n": 262144,
                "p": 1,
                "r": 8,
                "salt": "dbf6b497fb9889adb088113e1785ebfbe370da4a217fbef8dc049b70b8d3fbf2"
            },
            "mac": "b01c8314edbed99f341fdde99ba3238d7fad3e90a9d7e854b6f37bc86111ff17"
        },
        "id": "7bfb8f11-9813-7d1c-cbdc-2b6a9d5e7b46",
        "version": 3,
        "privateKey": null
    }];

    this.unlockAccount = function(address, password) {
        var ret = false;
        var key = null;

        for (var i = 0; i < self.accounts.length; i++) {
            if (self.accounts[i].address == address) {
                key = self.accounts[i];
            }
        }

        if (key) {
            var privateKey = keythereum.recover(password, key).toString('hex');
            self.accounts.forEach((account) => {
                if (account.address == address) {
                    account.privateKey = privateKey;
                    ret = true;
                }
            })
        }

        return ret;
    }

    this.clearAccount = function() {
        self.accounts = [];
    }

    this.addAccount = function(data) {
        var ret = true;
        if (typeof data == 'object') {
            self.accounts.push(data);
        } else if(typeof data == 'string'){
            var account = {
                address:undefined,
                privateKey:data,
            }
            account.address = keythereum.privateKeyToAddress(data);

            self.accounts.push(account);
        } else {
            ret = false;
        }

        return ret;
    }
}
